package com.heisenhub.api.logsapi.async;

import com.heisenhub.common.oauth.entity.UuaUser;
import com.heisenhub.common.oauth.holder.LoginUserHolder;
import com.heisenhub.logs.common.enums.LogsOperateEnums;
import com.heisnenhub.common.module.inter.BusinessTypeEnumsInter;
import com.heisenhub.logs.common.qo.GMQo;
import com.heisnenhub.common.module.config.AsyncManager;

public class LogsAsyncUtil {

    private LogsAsyncUtil() {
    }


    /**
     * 保存日志
     * @param gmQo
     */
    public static void saveOperateLog(GMQo gmQo){
        if(gmQo.getUser() ==null){
            UuaUser user = LoginUserHolder.loginUser();
            gmQo.setUser(user);
        }
        AsyncManager.me().execute(LogsAsyncFactory.saveLog(gmQo));
    }

    /**
     *  默认是操作成功的
     * @param user  用户
     * @param title  标题
     * @param enums  分类
     * @param businessUniqueCode 唯一标识
     * @param details 日志详情
     */
    public static void saveOperateLog(UuaUser user, String title, BusinessTypeEnumsInter enums, String businessUniqueCode, String details, boolean success, LogsOperateEnums logsOperateEnums){
        GMQo gmQo = new GMQo(user,title,enums,businessUniqueCode,details,success,logsOperateEnums);
        saveOperateLog(gmQo);
    }



    /**
     *  默认是操作成功的
     * @param title  标题
     * @param enums  分类
     * @param businessUniqueCode 唯一标识
     * @param details 日志详情
     */
    public static void saveOperateLog( String title, BusinessTypeEnumsInter enums, String businessUniqueCode, String details, LogsOperateEnums logsOperateEnums){
        GMQo gmQo = new GMQo(null,title,enums,businessUniqueCode,details ,logsOperateEnums);
        saveOperateLog(gmQo);
    }


    /**
     * @param enums  业务枚举
     * @param businessUniqueCode 唯一标识
     * @param details 日志详情
     */
    public static void saveOperateLog( BusinessTypeEnumsInter enums, String businessUniqueCode, String details, LogsOperateEnums logsOperateEnums){
        GMQo gmQo = new GMQo(null,enums.getDesc(),enums,businessUniqueCode,details ,logsOperateEnums);
        saveOperateLog(gmQo);
    }







}
